package com.lxj.group.controller;
import com.lxj.group.service.GroupService;
import com.lxj.utils.common.CommonResult;
import com.lxj.utils.entity.Group;
import com.lxj.utils.entity.RemoveRecord;
import com.lxj.utils.entity.TransferRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/group")
public class GroupController {
    @Autowired
    private GroupService groupService;

    @PostMapping("/findAll")
    public CommonResult findAll(Group group){
        return groupService.findAll(group);
    }
    @PostMapping("/delete")
    public CommonResult delete(Integer[] id){
        return groupService.delete(id);
    }
    @PostMapping("/add")
    public CommonResult add(Group group){
        return groupService.add(group);
    }
    @PostMapping("/findById")
    private CommonResult findById(Integer id){
        return groupService.findById(id);
    }
    @PostMapping("/edit")
    public CommonResult edit(Group group){
        return groupService.edit(group);
    }
    //查询所有未分组的学生，用来分配成员
    @PostMapping("/findAllUser")
    public CommonResult findStudent(Integer id){
        return groupService.findStudent(id);
    }
    @PostMapping("/findByGroupId")
    public CommonResult findByGroupId(Integer id){
        return groupService.findByGroupId(id);
    }
    @PostMapping("/addMember")
    public CommonResult addMember(Integer[] ids, Integer id){
        return groupService.addMember(ids,id);
    }
    @GetMapping("/deleteMember")
    public CommonResult deleteMember(Integer[] ids, Integer id){
        return groupService.deleteMember(id,ids);
    }
    @GetMapping("/selectMember")
    public CommonResult selectMember(Integer id){
        return groupService.selectMember(id);
    }

    /**
     * 查询人员调组的记录信息
     * @param removeRecord
     * @return
     */
    @PostMapping("/findAllRemoveRecord")
    public CommonResult findAllRemoveRecord(RemoveRecord removeRecord){
        return groupService.findAllRemoveRecord(removeRecord);
    }
    /**
     * 删除记录
     */
    @PostMapping("/deleteRecord")
    public CommonResult deleteRecord(Integer[] id){
        return groupService.deleteRecord(id);
    }
    /**
     * 小组点到根据username查询所属小组并获得小组所有成员
     */
    @PostMapping("/findByUsername")
    public CommonResult findByUsername(String username){
        return groupService.findByUsername(username);
    }
    @PostMapping("/findRecord")
    public CommonResult findRecord(TransferRecord transferRecord){
        return groupService.findRecord(transferRecord);
    }
}
